package org.framework.lazy.cloud.network.heartbeat.common.advanced.flow.proxy;

import io.netty.channel.Channel;

/**
 * 处理通道流量适配者 抽象类
 *
 * @see HandleChannelProxyFlowAdvanced
 */
public abstract class AbstractHandleChannelProxyFlowAdvanced implements HandleChannelProxyFlowAdvanced {

    /**
     * 是否支持当前这种类型
     *
     * @param channelProxyFlow 数据
     * @return boolean
     */
    @Override
    public boolean support(ChannelProxyFlow channelProxyFlow) {
        return doSupport(channelProxyFlow);
    }

    /**
     * 处理是否支持这种类型
     *
     * @param channelProxyFlow 数据
     * @return boolean
     */
    protected abstract boolean doSupport(ChannelProxyFlow channelProxyFlow);

    /**
     * 处理当前数据
     *
     * @param channel     当前通道
     * @param channelProxyFlow 通道数据
     */
    @Override
    public void handler(Channel channel, ChannelProxyFlow channelProxyFlow) {
        doHandler(channel, channelProxyFlow);
    }

    /**
     * 处理当前数据
     *
     * @param channel     当前通道
     * @param channelProxyFlow 通道数据
     */
    protected abstract void doHandler(Channel channel, ChannelProxyFlow channelProxyFlow);
}
